package com.dev.dream.exochatlockscreen;

import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;

import com.dev.dream.libs.preperences.CustomCheckBoxPreference;

public class SettingsSendMsgActivity extends PreferenceActivity implements
		OnPreferenceChangeListener {

	Preference preview, send_message, my_avatar;
	CustomCheckBoxPreference enable_send_msg;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.pre_send_msg_exo);

		enable_send_msg = (CustomCheckBoxPreference) findPreference("enable_send_message");
		enable_send_msg.setChecked(EXOChatKeypadPreferences.getInstance()
				.isSendMsg());
		enable_send_msg.setOnPreferenceChangeListener(this);

		preview = (Preference) findPreference("preview_send_msg");
		preview.setOnPreferenceClickListener(new OnPreferenceClickListener() {
			public boolean onPreferenceClick(Preference preference) {

				Intent i = new Intent(getApplicationContext(),
						LockScreenAppActivity.class);

				startActivity(i);

				return true;
			}
		});

		my_avatar = (Preference) findPreference("my_avatar");
		my_avatar.setOnPreferenceClickListener(new OnPreferenceClickListener() {
			public boolean onPreferenceClick(Preference preference) {

				Intent i = new Intent(getApplicationContext(), SelectAvatarActivity.class);

				startActivity(i);

				return true;
			}
		});

		send_message = (Preference) findPreference("message");
		send_message
				.setOnPreferenceClickListener(new OnPreferenceClickListener() {
					public boolean onPreferenceClick(Preference preference) {

						Intent i = new Intent(getApplicationContext(),
								SendMessageActivity.class);

						startActivity(i);

						return true;
					}
				});

	}

	@Override
	public boolean onPreferenceChange(Preference preference, Object newValue) {
		// TODO Auto-generated method stub
		if (preference == enable_send_msg) {
			EXOChatKeypadPreferences.getInstance().setSendMsg(
					(Boolean) newValue);

			enable_send_msg.setChecked(EXOChatKeypadPreferences.getInstance()
					.isSendMsg());

			return true;
		}
		return false;
	}

}
